namespace MoreLinq.Test;

using System.Collections;
using System.Collections.Generic;

static class ReadOnlyCollection
{
    public static IReadOnlyCollection<T> From<T>(params T[] items) =>
        new ListCollection<T[], T>(items);

    sealed class ListCollection<TList, T>(TList list) :
        IReadOnlyCollection<T>
        where TList : IList<T>
    {
        readonly TList list = list;

        public IEnumerator<T> GetEnumerator() => this.list.GetEnumerator();
        IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();

        public int Count => this.list.Count;
    }
}
